package com.itbaizhan.shopping_goods_service.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itbaizhan.shopping_common.pojo.SeckillGoods;
import com.itbaizhan.shopping_common.service.SecKillGoodsService;
import com.itbaizhan.shopping_goods_service.mapper.SecKillGoodsMaper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author spf
 * @date 2023/12/28
 * @time 9:34
 */

// 秒杀商品实现类
@Service
@Transactional
@Component
public class SecKillGoodsServiceImpl implements SecKillGoodsService {

    @Autowired
    private SecKillGoodsMaper secKillGoodsMaper;

    @Override
    public void add(SeckillGoods seckillGoods) {
        secKillGoodsMaper.insert(seckillGoods);
    }

    @Override
    public void update(SeckillGoods seckillGoods) {
        secKillGoodsMaper.updateById(seckillGoods);
    }

    @Override
    public Page<SeckillGoods> findPage(int page, int size) {
        return secKillGoodsMaper.selectPage(new Page(page, size), null);
    }
}
